@import '../../style/index.scss';

$upload: 'uni-upload';

.#{$upload} {
  &-default {
    .#{$upload}-image {
      position: relative;
      padding: 8px;
      border: 1px solid #d9d9d9;
      margin-top: 10px;
      cursor: pointer;
      transition: 2s all ease-in-out;
      @include round(4px);

      img {
        width: 48px;
        height: 48px;
      }
    }

    .#{$upload}-operation {
      position: absolute;
      top: 8px;
      right: 8px;
      color: $color-text-hint;
    }
  }

  &-card {
    display: flex;
    flex-wrap: wrap;

    .#{$upload}-item {
      position: relative;
      width: 104px;
      height: 104px;
      background-color: #fafafa;
      text-align: center;
      cursor: pointer;
      margin-right: 8px;
      margin-bottom: 8px;
      display: inline-block;
      box-sizing: border-box;
      @include round(4px);

      &:hover {
        .#{$upload}-item-info {
          &::before {
            opacity: 0.7;
          }
        }
      }

      &-info {
        position: relative;
        width: 100%;
        height: 100%;

        &::before {
          content: ' ';
          position: absolute;
          z-index: 1;
          background-color: rgba(0, 0, 0, 0.5);
          -webkit-transition: all 0.3s;
          transition: all 0.3s;
          width: 100%;
          height: 100%;
          opacity: 0;
        }

        &:hover {
          + .#{$upload}-operation {
            opacity: 0.7;
          }
        }
      }
    }

    .#{$upload}-image {
      padding: 8px;
      border: 1px solid #d9d9d9;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .#{$upload}-add {
      border: 1px dashed #d9d9d9;
      -webkit-transition: border-color 0.3s ease;
      transition: border-color 0.3s ease;
      vertical-align: top;
      font-size: 14px;
      font-variant: tabular-nums;
      line-height: $line-height-normal;
      color: $color-text-hint;
      padding: 0;
      list-style: none;
      outline: 0;
      @include round(4px);

      &:hover {
        border-color: $color-brand-normal;
      }

      .#{$upload}-add-image {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .#{$upload}-add-text {
        position: relative;

        &::before {
          content: ' ';
          width: 40px;
          height: 1px;
          background-color: $color-text-hint;
          @include center;
        }

        &::after {
          content: ' ';
          position: absolute;
          width: 40px;
          height: 1px;
          background-color: $color-text-hint;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%) rotate(90deg);
        }
      }
    }

    .#{$upload}-operation {
      color: #fff;
      opacity: 0;
      z-index: 1;
      @include center;

      &:hover {
        opacity: 0.7;
      }
    }
  }

  .uni-icon {
    cursor: pointer;
  }

  &-animate-leave {
    animation: uploadAnimateOut;
  }

  &-animate-enter {
    animation: uploadAnimateIn;
  }

  &-inline-enter {
    animation: uploadAnimateInlineIn;
  }

  &-inline-leave {
    animation: uploadAnimateInlineOut;
  }
}
@keyframes uploadAnimateIn {
  from {
    height: 0;
    margin: 0;
    opacity: 0;
    padding: 0;
  }
}
@keyframes uploadAnimationOut {
  to {
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
  }
}
@keyframes uploadAnimateInlineIn {
  from {
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
    padding: 0;
  }
}
@keyframes uploadAnimateInlineOut {
  to {
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
  }
}
